<?php

try {
	$debug = true;
	$profile = false;

	$root = dirname(__FILE__);
	$ds = DIRECTORY_SEPARATOR;
	set_include_path(	$root. $ds . PATH_SEPARATOR  										//this dir
									. $root . $ds . 'Library' . $ds . PATH_SEPARATOR 		//library
									. $root . $ds . 'Application' . $ds . PATH_SEPARATOR	//application
									. get_include_path());		//old path
	require_once 'Library/includes.php'; // Include path settings specific for local machine

	if ( $profile ) {
		require_once 'SmartL/Profiler.php';
		SmartL_Profiler::getInstance()->enable(true);
	}

	// Register autoload (required by Doctrine)
	require_once 'Zend/Loader.php';
	require_once 'Doctrine.php';
	Zend_loader::registerAutoload('Doctrine');

	// Helper include - temporary solution
	require_once 'SmartL/Doctrine/Template/I18n.php';

	// Initialize SmartL_Application
	require_once 'SmartL/Application.php';
	$application = SmartL_Application::getInstance();

	//Global cache for config - uncomment for enable config caching
	/*require_once 'Zend/Cache.php';
	SmartL_Config::setCache(Zend_Cache::factory('Core','File',array('lifetime'=>60),
		array('cache_dir'=>dirname(__FILE__).'/Application/Data/ConfigCache')));*/

	// Init application
	$application->init(dirname(__FILE__), "Application" . $ds . "Config", null /*Insert here instance of your SmartL_Application_Login_Interface plugin*/ );

	// Register custom application plugins - example
	/*require_once 'Demo/Plugin.php';
	Zend_Controller_Front::getInstance()
        ->registerPlugin(new Demo_Plugin()); */

	// Start dispatching
	$application->start();
}
catch (Exception $e) {
	if ( $debug ) {
		throw $e;
	}
	else {
		include 'Public/error.html';
	}
}